package com.zpark.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zhangbing
 * @date
 * @description TODO 配置类
 */
@Configuration //表明是配置类
@EnableSwagger2  //开启Swagger2
public class Swagger2Config {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
                //配置的是对哪些内容进行生成 生成api
                .apis(RequestHandlerSelectors.basePackage("com.zpark.controller"))
                .paths(PathSelectors.any()).build();
    }

    //创建一个apiInfo  API文档的详细信息参数
    public ApiInfo apiInfo(){

     return  new ApiInfoBuilder()
                //页面标题
             .title("SpringBoot整合Swagger2构建RestFul API")
             //构建人
             .contact(new Contact("zhangbing","http://www.baidu.com",""))
             //版本
             .version("1.0")
             //描述
             .description("API 接口文档")
             .build();
    }

}
